Skip to content

feat(examples): add push_button example#2305

Open
jcsxdev wants to merge 1 commit into
gtk-rs:mainfrom
jcsxdev:examples/push-button
Open

feat(examples): add push_button example#2305
jcsxdev wants to merge 1 commit into
gtk-rs:mainfrom
jcsxdev:examples/push-button

Conversation

@jcsxdev
Copy link
Copy Markdown

@jcsxdev jcsxdev commented May 17, 2026

This adds a new example demonstrating how to properly handle independent "press" and "release" events on a gtk::Button using both mouse and keyboard interactions.

It addresses common UI implementation details by:

  • Combining GestureClick (mouse) and EventControllerKey (keyboard).
  • Ignoring OS-level key autorepeat to prevent visual flickering.
  • Manually managing gtk::StateFlags::ACTIVE for consistent visual feedback.
  • Safely managing UI state using Rc<Cell<bool>> and weak references.

@jcsxdev jcsxdev requested a review from bilelmoussaoui as a code owner May 17, 2026 19:24
@jcsxdev
Copy link
Copy Markdown
Author

jcsxdev commented May 17, 2026

Related to #1308 .

This adds a new example demonstrating how to properly handle independent
"press" and "release" events on a `gtk::Button` using both mouse and
keyboard interactions.

It addresses common UI implementation details by:

* Combining `GestureClick` (mouse) and `EventControllerKey` (keyboard).
* Ignoring OS-level key autorepeat to prevent visual flickering.
* Manually managing `gtk::StateFlags::ACTIVE` for consistent visual feedback.
* Safely managing UI state using `Rc<Cell<bool>>` and weak references.
@jcsxdev jcsxdev force-pushed the examples/push-button branch from 923578e to 5105184 Compare May 17, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant